package com.zt.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zt.feign.UserFeign;
import com.zt.service.FinancialProductService;
import com.zt.system.FinancialProduct;
import com.zt.system.FinancialTransaction;
import com.zt.service.FinancialTransactionService;
import com.zt.mapper.FinancialTransactionMapper;
import com.zt.user.UserInfo;
import com.zt.utils.Result;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author 不.凌
* @description 针对表【financial_transaction】的数据库操作Service实现
* @createDate 2024-09-03 17:43:57
*/
@Service
public class FinancialTransactionServiceImpl extends ServiceImpl<FinancialTransactionMapper, FinancialTransaction>
    implements FinancialTransactionService{
    @Resource
    private FinancialTransactionMapper financialTransactionMapper;
    @Resource
    private UserFeign userFeign;
    @Resource
    private FinancialProductService financialProductService;

    @Override
    public Result financialTransactionList() {
        List<FinancialTransaction> financialTransaction = financialTransactionMapper.selectList(null);
        for(FinancialTransaction financialTransaction1: financialTransaction){
            UserInfo userInfoById = userFeign.getUserInfoById(financialTransaction1.getUserId());
            financialTransaction1.setUserInfo(userInfoById);
            FinancialProduct financialProductById = financialProductService.getFinancialProductById(financialTransaction1.getProductId());
            financialTransaction1.setFinancialProduct(financialProductById);
        }
        return Result.success(financialTransaction);
    }
}